//
//  SSDKAppUserInfo.m
//  SuperSDK
//  运行稳定后考虑废弃掉该类
//  Created by wyht－ios－dev on 15/10/7.
//  Copyright © 2015年 WYHT. All rights reserved.
//

#import "SSDKAppUserInfo.h"
#import "SSDKDataKeys.h"

@implementation SSDKAppUserInfo

- (instancetype) initWithUserInfo:(SSDKUserInfo *)userInfo {
    self = [super init];
    
    if (self) {
        self.status = userInfo.status;
        self.data=[[NSMutableDictionary alloc] initWithDictionary:self.data copyItems:YES];
        self.extra = userInfo.extra;
        self.common = userInfo.common;
        
        if (self.isOk) {
            [self.data setObject:userInfo.superSDKUid forKey:SUPERSDK_UID];
            //兼容以前的格式
            [self.data setObject:userInfo.superSDKUid forKey:UID];
//            self.channelId = userInfo.channelId;
//            self.sdkId = userInfo.sdkId;
//            
//            if ([userInfo extraWithKey:APP_DATA]) {
//                self.appData = [userInfo extraWithKey:APP_DATA];
//            }
        }
        else {
            [self setError:userInfo.error
                  withCode:userInfo.errorNo
                   withMsg:userInfo.errorMsg];
        }
    }
    
    return self;
}

- (NSString *) token {
    return [self dataWithKey:SUPERSDK_TOKEN];
}

- (NSString *) uid {
    return [self dataWithKey:UID];
}

- (NSString *) supersdk_uid {
    return [self dataWithKey:SUPERSDK_UID];
}

- (NSString *) appData {
    return [self extraWithKey:APP_DATA];
}

@end
